home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / OLE2BOOK.ZIP / CHAP09.ZIP / CHAP09 / PATRON / IADVSINK.CPP < prev    next >
C/C++ Source or Header  |  1993-06-13  |  4KB  |  209 lines

  1. /*
  2.  * IADVSINK.CPP
  3.  *
  4.  * Implementation of the IAdviseSink interface for Patron's tenants.
  5.  *
  6.  * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  7.  *
  8.  * Kraig Brockschmidt, Software Design Engineer
  9.  * Microsoft Systems Developer Relations
  10.  *
  11.  * Internet  :  kraigb@microsoft.com
  12.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  13.  */
  14.  
  15.  
  16. #include "patron.h"
  17.  
  18.  
  19. /*
  20.  * CImpIAdviseSink::CImpIAdviseSink
  21.  * CImpIAdviseSink::~CImpIAdviseSink
  22.  *
  23.  * Parameters (Constructor):
  24.  *  pTenant         LPTENANT of the tenant we're in.
  25.  *  punkOuter       LPUNKNOWN to which we delegate.
  26.  */
  27.  
  28. CImpIAdviseSink::CImpIAdviseSink(LPTENANT pTenant, LPUNKNOWN punkOuter)
  29.     {
  30.     m_cRef=0;
  31.     m_pTen=pTenant;
  32.     m_punkOuter=punkOuter;
  33.     return;
  34.     }
  35.  
  36. CImpIAdviseSink::~CImpIAdviseSink(void)
  37.     {
  38.     return;
  39.     }
  40.  
  41.  
  42.  
  43.  
  44. /*
  45.  * CImpIAdviseSink::QueryInterface
  46.  * CImpIAdviseSink::AddRef
  47.  * CImpIAdviseSink::Release
  48.  *
  49.  * Purpose:
  50.  *  IUnknown members for CImpIAdviseSink object.
  51.  */
  52.  
  53. STDMETHODIMP CImpIAdviseSink::QueryInterface(REFIID riid, LPVOID FAR *ppv)
  54.     {
  55.     return m_punkOuter->QueryInterface(riid, ppv);
  56.     }
  57.  
  58.  
  59. STDMETHODIMP_(ULONG) CImpIAdviseSink::AddRef(void)
  60.     {
  61.     ++m_cRef;
  62.     return m_punkOuter->AddRef();
  63.     }
  64.  
  65. STDMETHODIMP_(ULONG) CImpIAdviseSink::Release(void)
  66.     {
  67.     --m_cRef;
  68.     return m_punkOuter->Release();
  69.     }
  70.  
  71.  
  72.  
  73.  
  74. /*
  75.  * IAdviseSink::OnDataChange
  76.  *
  77.  * Unused since we don't IDataObject::Advise.
  78.  */
  79.  
  80. STDMETHODIMP_(void) CImpIAdviseSink::OnDataChange(LPFORMATETC pFEIn
  81.     , LPSTGMEDIUM pSTM)
  82.     {
  83.     return;
  84.     }
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92. /*
  93.  * IAdviseSink::OnViewChange
  94.  *
  95.  * Purpose:
  96.  *  Notifes the advise sink that presentation data changed in the data
  97.  *  object to which we're connected providing the right time to update
  98.  *  displays using such presentations.
  99.  *
  100.  * Parameters:
  101.  *  dwAspect        DWORD indicating which aspect has changed.
  102.  *  lindex          LONG indicating the piece that changed.
  103.  *
  104.  * Return Value:
  105.  *  None
  106.  */
  107.  
  108. STDMETHODIMP_(void) CImpIAdviseSink::OnViewChange(DWORD dwAspect, LONG lindex)
  109.     {
  110.     //This only requires a repaint, which our tenant makes simple for us.
  111.     //CHPATER9MOD
  112.     //Repaint only if this is the right aspect
  113.     if (dwAspect==m_pTen->m_fe.dwAspect)
  114.         m_pTen->Repaint();
  115.     //End CHAPTER9MOD
  116.  
  117.     m_pTen->m_pPG->m_fDirty=TRUE;
  118.     return;
  119.     }
  120.  
  121.  
  122.  
  123.  
  124.  
  125. /*
  126.  * IAdviseSink::OnRename
  127.  *
  128.  * Purpose:
  129.  *  Informs the advise sink that an IOleObject has been renamed, primarily
  130.  *  when its linked.
  131.  *
  132.  * Parameters:
  133.  *  pmk             LPMONIKER providing the new name of the object
  134.  *
  135.  * Return Value:
  136.  *  None
  137.  */
  138.  
  139. STDMETHODIMP_(void) CImpIAdviseSink::OnRename(LPMONIKER pmk)
  140.     {
  141.     /*
  142.      * As a container this is unimportant to us since it really
  143.      * tells the handler's implementation of IOleLink that the
  144.      * object's moniker has changed.  Since we get this call
  145.      * from the handler, we don't have to do anything ourselves.
  146.      */
  147.     return;
  148.     }
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155. /*
  156.  * IAdviseSink::OnSave
  157.  *
  158.  * Purpose:
  159.  *  Informs the advise sink that the OLE object has been saved
  160.  *  persistently.  The primary purpose of this is for containers that
  161.  *  want to make optimizations for objects that are not in a saved
  162.  *  state, so on this you have to disable such optimizations.
  163.  *
  164.  * Parameters:
  165.  *  None
  166.  *
  167.  * Return Value:
  168.  *  None
  169.  */
  170.  
  171. STDMETHODIMP_(void) CImpIAdviseSink::OnSave(void)
  172.     {
  173.     /*
  174.      * A Container has nothing to do here as this notification is only
  175.      * useful when we have an ADVFCACHE_ONSAVE advise set up, which
  176.      * we don't.  So we ignore it.
  177.      */
  178.     return;
  179.     }
  180.  
  181.  
  182.  
  183.  
  184.  
  185. /*
  186.  * IAdviseSink::OnClose
  187.  *
  188.  * Purpose:
  189.  *  Informs the advise sink that the OLE object has closed and is
  190.  *  no longer bound in any way.
  191.  *
  192.  * Parameters:
  193.  *  None
  194.  *
  195.  * Return Value:
  196.  *  None
  197.  */
  198.  
  199. STDMETHODIMP_(void) CImpIAdviseSink::OnClose(void)
  200.     {
  201.     /*
  202.      * This doesn't have anything to do with us again as it's only used
  203.      * to notify the handler's IOleLink implementation of the change
  204.      * in the object.  We don't have to do anything since we'll also
  205.      * get an IOleClientSite::OnShowWindow(FALSE) to tell us to repaint.
  206.      */
  207.     return;
  208.     }
  209.